﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site2.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Aluno
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        Aluno</h2>
    <form action="/Cadastro/<%= ViewData["ra"] == null ? "Aluno" : "AlterarCadastro" %>" method="post">
    <table>
        <tr>
            <td>
                Nome:
            </td>
            <td>
                <input type="text" name="txtNome" id="txtNome" maxlength="60" value="<%= ViewData["nome"] %>" />
            </td>
        </tr>
        <tr>
            <td>
                RA:
            </td>
            <td>
                <input type="text" name="txtRa" id="txtRa" maxlength="6" value="<%= ViewData["ra"] %>"  <%= ViewData["ra"] == null ? "" : "readonly='readonly'" %> />
            </td>
        </tr>
    </table>
    <input type="submit" value="<%= ViewData["ra"] == null ? "Cadastrar" : "Alterar" %>" />
    </form>
    <br />
    <br />
    <table>
        <tr>
            <th></th>
            <th></th>
            <th>
                Nome:
            </th>
            <th>
                RA:
            </th>
            
        </tr>
        <%  
            
            if (ViewData["alunos"] != null)
            {
                List<MvcApplicationClasses.Models.tbAluno> alunos = (List<MvcApplicationClasses.Models.tbAluno>)ViewData["alunos"];
                foreach (MvcApplicationClasses.Models.tbAluno a in alunos)
                {
        %>
                <tr>
                    <td>
                        
                        <a href="/Cadastro/ExcluirAluno/<%= a.Ra %>">
                            <img src="../../Images/delete.png" width="20px" /></a>
                    </td>
                    <td>
                        
                        <a href="/Cadastro/Aluno/<%= a.Ra %>">
                            <img src="../../Images/alterar.jpg" width="20px" /></a>
                    </td>
                    <td>
                        <% = a.Nome%>     
                    </td>
                    <td>
                        <% = a.Ra%>
                    </td>
                    
                </tr>
        <%
                }
            }
        %>
    </table>
</asp:Content>
